#include<iostream>
using namespace std;
const int N = 1e5 + 10;
int a[N], b[N], c[N], d[N];
int main()
{
	int x, y, g, k, flag = 0;
	int r; cin >> r;
	for (int i = 1; i <= r; i++)
	{
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	cin >> x >> y;
	for (int i = r; i >= 1; i--)
	{
		if (a[i] <= x && b[i] <= y && a[i] + c[i] >= x && b[i] + d[i] >= y)
		{
			flag = 1;
			cout << i << endl;
			break;
		}
	}
	if (flag == 0) cout << -1 << endl;
	return 0;
}